package com.jamesacurtis.MyBudget;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.MonthDisplayHelper;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;

public class AddIncome extends Activity {
    Button addIncome, clearButton;
    RadioButton wage, pension, socialSecurity, support, other, once, other1, biweekly, monthly;
    String category, occur;
    int incomeAmount;
	//Your member variable declaration here

	// Called when the activity is first created.
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.new_income);
        
        setupControls();
        
        addIncome.setOnClickListener(new Button.OnClickListener(){

			public void onClick(View v) {
			   setCategory();
			   getIncome();
			   
             
				
			}


        	
        	
        });
        
       clearButton.setOnClickListener(new Button.OnClickListener(){

		public void onClick(View v) {
			
			
		}
    	   
    	   
    	   
       });
        
        //Toast.makeText(AddIncome.this, "NOT YET IMPLEMENTED", Toast.LENGTH_SHORT).show();
        
	}
	private void getIncome() {
		AlertDialog.Builder alert = new AlertDialog.Builder(this);

		alert.setTitle("Add Income");
		alert.setMessage("Please Enter Amount");

		// Set an EditText view to get user input 
		final EditText input = new EditText(this);
		alert.setView(input);

		alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int whichButton) {
		  String value = input.getText().toString();
		  //convert that value to int 
          incomeAmount = Integer.parseInt(value);	
          Toast.makeText(AddIncome.this, "Amount Entered: " + incomeAmount + " " +category + " " + occur, Toast.LENGTH_LONG).show();
          
		  }
		});

		alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
		  public void onClick(DialogInterface dialog, int whichButton) {
		    // Canceled.
			  
			  Toast.makeText(AddIncome.this, "Amount Entered: " + incomeAmount, Toast.LENGTH_LONG).show();
		  }
		});

		alert.show();
		
		
	}
	private void setCategory() {
    	if(wage.isChecked()){
			 category = "Wages";
			 
		 }
		 if(pension.isChecked()){
			 category = "Pension";
			 
		 }
		 if(socialSecurity.isChecked()){
			 category = "Social Security";
			 
		 }if(support.isChecked()){
			 category = "Support";
			 
		 }
		 if(other.isChecked()){
			 category = "Other";
			 
		 }
		 if(once.isChecked()){
			 occur = "once";
			 
		 }
		 if(biweekly.isChecked()){
			 occur = "Bi-Weekly";
			 
		 }if(monthly.isChecked()){
			 occur = "Monthly";
			 
		 }
		 if(other1.isChecked()){
			 occur = "Other";
			 
		 }
		
	}
	private void setupControls() {
	    addIncome = (Button)findViewById(R.id.add_button);
	    clearButton = (Button)findViewById(R.id.clear_button);
	    wage = (RadioButton)findViewById(R.id.wage);
	    pension = (RadioButton)findViewById(R.id.pension);
	    socialSecurity = (RadioButton)findViewById(R.id.socialsecurity);
	    support = (RadioButton)findViewById(R.id.support);
	    other = (RadioButton)findViewById(R.id.other);
	    other1 = (RadioButton)findViewById(R.id.other1);
	    once = (RadioButton)findViewById(R.id.once);
	    biweekly = (RadioButton)findViewById(R.id.biweekly);
	    monthly = (RadioButton)findViewById(R.id.monthly);
	    
	    
	}
	
}